package com.ecom.common.service;

import com.ecom.common.dao.OrderDao;
import com.ecom.common.dao.ProductDao;
import com.ecom.common.model.*;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by jimmy on 7/31/14.
 */
@Service
public class OrderService {

    private static final Logger logger = Logger.getLogger(ProductService.class);

    @Autowired
    OrderDao orderDao;

    public void submitOrder(List<Product> products, Address address, PayOption payOption, User user, ShipMethod shipMethod) {

        String confirmationNumber = new String();

        orderDao.insertAddress(address);
        orderDao.insertPayOption(payOption);
        orderDao.insertUserHasPayOption(user.getUsername(), payOption.getAccountNum());
        orderDao.insertOrder(products, confirmationNumber, user.getUsername(),  shipMethod.getMid(), payOption.getAccountNum());

    }

    public List<ShipMethod> getShipMethods() {
        return orderDao.getShipMethods();
    }
}
